
//
//  GYHVisitorLoginView.swift
//  sinaWeibo_18
//
//  Created by 高勇华 on 15/10/6.
//  Copyright © 2015年 高勇华. All rights reserved.
//

import UIKit

protocol GYHVisitorLoginViewDelegate:NSObjectProtocol{

    func visitorWithregister()
    
    func visitorWithLogin()

}

class GYHVisitorLoginView: UIView {
 
    weak var visitorDelegate : GYHVisitorLoginViewDelegate?
    
    @IBOutlet weak var iconHouse: UIImageView!
    
    
    
    @IBOutlet weak var smallIcon: UIImageView!
    
   
    @IBOutlet weak var messageLable: UILabel!
    
    func visitorLonIngView(iconName name:String , textLable: String ,isHome: Bool = false){
    
    
    self.iconHouse.image = UIImage(named: name)
    
        self.smallIcon.hidden = !isHome
        
        if isHome{
        
        startAnimation()
        
        }
        
        
    self.messageLable.text = textLable
        
        
    
    
    }
    
  private  func startAnimation(){
    
//    let ani = CABasicAnimation(keyPath: "transform.rotation")
//        
//      ani.repeatCount = MAXFLOAT
//      ani.duration = 15
//        ani.toValue = 2 * M_PI
//        ani.removedOnCompletion = false
//        smallIcon.layer.addAnimation(ani, forKey: nil)
    
    let anim = CABasicAnimation(keyPath: "transform.rotation")
    
    
    anim.repeatCount = MAXFLOAT
    
    
    anim.duration = 15
    
    anim.toValue = 2 * M_PI
    
    anim.removedOnCompletion = false
    
    smallIcon.layer.addAnimation(anim, forKey: nil)
    
    
    
    
    }
    
    
    @IBAction func registerBut(sender: AnyObject) {
        
        visitorDelegate?.visitorWithregister()
        
    }
    
   
    
    @IBAction func longBut(sender: AnyObject) {
        
       visitorDelegate?.visitorWithLogin()
        
        
    }
    
    
    
}
